package com.yxh.activity;

import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.TextView;

import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.yxh.R;
import com.yxh.dto.UserDto;
import com.yxh.util.Options;

/***
 * 用户二维码
 * 
 * @author work
 * 
 */
public class UserForQrCodeActivity extends BaseActivity implements
		OnClickListener {

	private ImageView qrCodeImg;// 用户二维码
	private TextView userNameTv;// 用户姓名

	private DisplayImageOptions options;
	private ImageLoader imageLoader;
	private UserDto userInfo;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		this.setContentView(R.layout.activity_usercenter_qrcode);

		initViews();

		initUserInfo();

		overridePendingTransition(R.anim.enter_righttoleft, R.anim.noanim);
	}

	private void initViews() {

		((TextView) findViewById(R.id.head_layout_tv)).setText("二维码");

		qrCodeImg = (ImageView) findViewById(R.id.qrcode_img1);
		userNameTv = (TextView) findViewById(R.id.qrcode_tv1);
	}

	private void initUserInfo() {
		imageLoader = ImageLoader.getInstance();
		if (!imageLoader.isInited()) {
			Options.initImageLoaderConfiguration(ImageLoader.getInstance(),
					mContext);
		}
		options = Options.getListOptions3();
		userInfo = getcurrentUser();
		if (userInfo != null) {

			if (!TextUtils.isEmpty(userInfo.userQrCode))
				imageLoader.displayImage(userInfo.userQrCode, qrCodeImg,
						options);

			if (!TextUtils.isEmpty(userInfo.nickname))
				userNameTv
						.setText(String.format("我的ID: %s", userInfo.nickname));

		}
	}

	@Override
	public void onClick(View view) {

	}
}
